import Vue from "vue";
import VueRouter from 'vue-router';

Vue.use(VueRouter)

//处理重复触发编程式导航的bug
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
import routes from "routes/routes";
const router = new VueRouter({
    routes,
    mode: 'history',
    scrollBehavior() {
        return { x: 0, y: 0 }
    }
})
import { defined } from "./defined";
defined(router)
export default router